package me.gijspennings.jumpandduck.level.tiles;

import me.gijspennings.jumpandduck.graphics.AnimatedSprite;
import me.gijspennings.jumpandduck.graphics.Screen;
import me.gijspennings.jumpandduck.graphics.Sprite;

public abstract class Tile {

    public static Tile darkStone = new DarkStoneTile();
    public static Tile lightStone = new LightStoneTile();
    
    private final Sprite sprite;
    
    public Tile(Sprite sprite) {
        this.sprite = sprite;
    }
    public Tile(AnimatedSprite sprite) {
        this.sprite = sprite;
    }
    
    public void update() {
        if (sprite instanceof AnimatedSprite) ((AnimatedSprite) sprite).update();
    }
    public void render(Screen screen, int x, int y) {
        // Switch from tile precision to pixel precision
        x = x * 16;
        y = y * 16;
        screen.renderTile(this, x, y);
    }
    
    public Sprite getSprite() {
        return sprite;
    }
}
